smalltalk.addPackage('Easnoth-Core', {});
smalltalk.addClass('Cell', smalltalk.Object, ['drawedObjects', 'x', 'y'], 'Easnoth-Core');
smalltalk.addMethod(
"_draw",
smalltalk.method({
selector: "draw",
fn: function () {
    var self = this;
    smalltalk.send(self['@drawedObjects'], "_do_", [function (drawedObject) {return ($receiver = drawedObject) != nil && $receiver != undefined ? function () {return smalltalk.send(drawedObject, "_drawX_y_", [smalltalk.send(self, "_x", []), smalltalk.send(self, "_y", [])]);}() : nil;}]);
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_drawedObjects",
smalltalk.method({
selector: "drawedObjects",
fn: function () {
    var self = this;
    return self['@drawedObjects'];
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_drawedObjects_",
smalltalk.method({
selector: "drawedObjects:",
fn: function (value) {
    var self = this;
    self['@drawedObjects'] = value;
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_tile",
smalltalk.method({
selector: "tile",
fn: function () {
    var self = this;
    return smalltalk.send(self['@drawedObjects'], "_at_", [1]);
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_tile_",
smalltalk.method({
selector: "tile:",
fn: function (aTile) {
    var self = this;
    smalltalk.send(self['@drawedObjects'], "_at_put_", [1, aTile]);
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_x",
smalltalk.method({
selector: "x",
fn: function () {
    var self = this;
    return self['@x'];
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_x_",
smalltalk.method({
selector: "x:",
fn: function (value) {
    var self = this;
    self['@x'] = value;
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_y",
smalltalk.method({
selector: "y",
fn: function () {
    var self = this;
    return self['@y'];
    return self;
}
}),
smalltalk.Cell);

smalltalk.addMethod(
"_y_",
smalltalk.method({
selector: "y:",
fn: function (value) {
    var self = this;
    self['@y'] = value;
    return self;
}
}),
smalltalk.Cell);


smalltalk.addMethod(
"_newWithContext_cellArray_coods_",
smalltalk.method({
selector: "newWithContext:cellArray:coods:",
fn: function (aContext, aCellArray, coods) {
    var self = this;
    return function ($rec) {smalltalk.send($rec, "_drawedObjects_", [smalltalk.send(smalltalk.Array || Array, "_new_", [8])]);smalltalk.send($rec, "_x_", [smalltalk.send(coods, "_at_", [1])]);smalltalk.send($rec, "_y_", [smalltalk.send(coods, "_at_", [2])]);smalltalk.send($rec, "_tile_", [smalltalk.send(smalltalk.Tile || Tile, "_newWithContext_index_", [aContext, smalltalk.send(aCellArray, "_at_", [1])])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(self, "_new", []));
    return self;
}
}),
smalltalk.Cell.klass);


smalltalk.addClass('DrawedObject', smalltalk.Object, ['image', 'context'], 'Easnoth-Core');
smalltalk.addMethod(
"_context",
smalltalk.method({
selector: "context",
fn: function () {
    var self = this;
    return self['@context'];
    return self;
}
}),
smalltalk.DrawedObject);

smalltalk.addMethod(
"_context_",
smalltalk.method({
selector: "context:",
fn: function (aCtx) {
    var self = this;
    self['@context'] = aCtx;
    return self;
}
}),
smalltalk.DrawedObject);

smalltalk.addMethod(
"_displayX_y_",
smalltalk.method({
selector: "displayX:y:",
fn: function (aX, aY) {
    var self = this;
    smalltalk.send(smalltalk.send(self, "_context", []), "_drawImage_x_y_", [smalltalk.send(self, "_image", []), aX, aY]);
    return self;
}
}),
smalltalk.DrawedObject);

smalltalk.addMethod(
"_drawX_y_",
smalltalk.method({
selector: "drawX:y:",
fn: function (aX, aY) {
    var self = this;
    smalltalk.send(self, "_subclassResponsibility", []);
    return self;
}
}),
smalltalk.DrawedObject);

smalltalk.addMethod(
"_image",
smalltalk.method({
selector: "image",
fn: function () {
    var self = this;
    return self['@image'];
    return self;
}
}),
smalltalk.DrawedObject);

smalltalk.addMethod(
"_image_",
smalltalk.method({
selector: "image:",
fn: function (anImage) {
    var self = this;
    self['@image'] = anImage;
    return self;
}
}),
smalltalk.DrawedObject);

smalltalk.addMethod(
"_initializeContext_index_",
smalltalk.method({
selector: "initializeContext:index:",
fn: function (aCtx, anIndex) {
    var self = this;
    smalltalk.send(self, "_context_", [aCtx]);
    smalltalk.send(self, "_image_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_arrayImg", []), "_atIndex_", [anIndex])]);
    return self;
}
}),
smalltalk.DrawedObject);


smalltalk.DrawedObject.klass.iVarNames = ['arrayImg'];
smalltalk.addMethod(
"_arrayImg",
smalltalk.method({
selector: "arrayImg",
fn: function () {
    var self = this;
    return self['@arrayImg'];
    return self;
}
}),
smalltalk.DrawedObject.klass);

smalltalk.addMethod(
"_arrayImg_",
smalltalk.method({
selector: "arrayImg:",
fn: function (anArray) {
    var self = this;
    self['@arrayImg'] = anArray;
    return self;
}
}),
smalltalk.DrawedObject.klass);


smalltalk.addClass('Ground', smalltalk.DrawedObject, [], 'Easnoth-Core');
smalltalk.addMethod(
"_drawX_y_",
smalltalk.method({
selector: "drawX:y:",
fn: function (aX, aY) {
    var self = this;
    var ctx = nil;
    ctx = smalltalk.send(self, "_context", []);
    (function ($rec) {smalltalk.send($rec, "_save", []);smalltalk.send($rec, "_translate_y_", [($receiver = aX).klass === smalltalk.Number ? $receiver + 45 : smalltalk.send($receiver, "__plus", [45]), ($receiver = aY).klass === smalltalk.Number ? $receiver - 7 : smalltalk.send($receiver, "__minus", [7])]);smalltalk.send($rec, "_scale_y_", [1, 0.5]);smalltalk.send($rec, "_rotate_", [($receiver = smalltalk.send(smalltalk.Number || Number, "_pi", [])).klass === smalltalk.Number ? $receiver / 4 : smalltalk.send($receiver, "__slash", [4])]);return smalltalk.send($rec, "_scale_y_", [1.4, 1.23]);}(ctx));
    smalltalk.send(self, "_displayX_y_", [0, 0]);
    smalltalk.send(ctx, "_restore", []);
    return self;
}
}),
smalltalk.Ground);



smalltalk.addClass('OverTile', smalltalk.Ground, [], 'Easnoth-Core');

smalltalk.addMethod(
"_newWithContext_index_",
smalltalk.method({
selector: "newWithContext:index:",
fn: function (aContext, anIndex) {
    var self = this;
    return function ($rec) {smalltalk.send($rec, "_initializeContext_index_", [aContext, anIndex]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(self, "_new", []));
    return self;
}
}),
smalltalk.OverTile.klass);


smalltalk.addClass('Tile', smalltalk.Ground, ['isWall'], 'Easnoth-Core');
smalltalk.addMethod(
"_isWall",
smalltalk.method({
selector: "isWall",
fn: function () {
    var self = this;
    return self['@isWall'];
    return self;
}
}),
smalltalk.Tile);

smalltalk.addMethod(
"_isWall_",
smalltalk.method({
selector: "isWall:",
fn: function (aBoolean) {
    var self = this;
    self['@isWall'] = aBoolean;
    return self;
}
}),
smalltalk.Tile);


smalltalk.addMethod(
"_newWithContext_index_",
smalltalk.method({
selector: "newWithContext:index:",
fn: function (aContext, anIndex) {
    var self = this;
    return function ($rec) {smalltalk.send($rec, "_initializeContext_index_", [aContext, anIndex]);smalltalk.send($rec, "_isWall_", [false]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(self, "_new", []));
    return self;
}
}),
smalltalk.Tile.klass);


smalltalk.addClass('OverGround', smalltalk.DrawedObject, ['hp'], 'Easnoth-Core');
smalltalk.addMethod(
"_hp",
smalltalk.method({
selector: "hp",
fn: function () {
    var self = this;
    return self['@hp'];
    return self;
}
}),
smalltalk.OverGround);

smalltalk.addMethod(
"_hp_",
smalltalk.method({
selector: "hp:",
fn: function (aNumber) {
    var self = this;
    self['@hp'] = aNumber;
    return self;
}
}),
smalltalk.OverGround);



smalltalk.addClass('Building', smalltalk.OverGround, [], 'Easnoth-Core');


smalltalk.addClass('Monster', smalltalk.OverGround, [], 'Easnoth-Core');


smalltalk.addClass('Map', smalltalk.Object, ['canvas', 'width', 'height', 'mapX', 'mapY', 'cells'], 'Easnoth-Core');
smalltalk.addMethod(
"_canvas",
smalltalk.method({
selector: "canvas",
fn: function () {
    var self = this;
    return self['@canvas'];
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_canvasId",
smalltalk.method({
selector: "canvasId",
fn: function () {
    var self = this;
    return "#main";
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_canvasPadding",
smalltalk.method({
selector: "canvasPadding",
fn: function () {
    var self = this;
    return 40;
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_cells",
smalltalk.method({
selector: "cells",
fn: function () {
    var self = this;
    return self['@cells'];
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_cells_",
smalltalk.method({
selector: "cells:",
fn: function (anArray) {
    var self = this;
    self['@cells'] = anArray;
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_height",
smalltalk.method({
selector: "height",
fn: function () {
    var self = this;
    return self['@height'];
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_height_",
smalltalk.method({
selector: "height:",
fn: function (aLength) {
    var self = this;
    self['@height'] = aLength;
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_initialize",
smalltalk.method({
selector: "initialize",
fn: function () {
    var self = this;
    smalltalk.send(self, "_initialize", [], smalltalk.Map.superclass || nil);
    self['@canvas'] = smalltalk.send(smalltalk.TagBrush || TagBrush, "_new", []);
    smalltalk.send(smalltalk.send(self, "_canvas", []), "_initializeFromJQuery_canvas_", [smalltalk.send(smalltalk.send(self, "_canvasId", []), "_asJQuery", []), smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_onJQuery_", [smalltalk.send("body", "_asJQuery", [])])]);
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_initializeCellsWithMapArray_",
smalltalk.method({
selector: "initializeCellsWithMapArray:",
fn: function (aMapArray) {
    var self = this;
    var sin45 = nil;
    var sin15 = nil;
    var sin135 = nil;
    var sin75 = nil;
    var cell = nil;
    var xpos = nil;
    var ypos = nil;
    var temp = nil;
    var cood = nil;
    sin45 = 0.707106781;
    sin15 = 0.258819045;
    sin135 = 0.233445364;
    sin75 = 0.965925826;
    smalltalk.send(aMapArray, "_withIndexDo_", [function (row, i) {return smalltalk.send(row, "_withIndexDo_", [function (cellArray, j) {temp = ($receiver = j).klass === smalltalk.Number ? $receiver + smalltalk.send(($receiver = ($receiver = i).klass === smalltalk.Number ? $receiver + 1 : smalltalk.send($receiver, "__plus", [1])).klass === smalltalk.Number ? $receiver / 2 : smalltalk.send($receiver, "__slash", [2]), "_truncated", []) : smalltalk.send($receiver, "__plus", [smalltalk.send(($receiver = ($receiver = i).klass === smalltalk.Number ? $receiver + 1 : smalltalk.send($receiver, "__plus", [1])).klass === smalltalk.Number ? $receiver / 2 : smalltalk.send($receiver, "__slash", [2]), "_truncated", [])]);xpos = ($receiver = ($receiver = ($receiver = ($receiver = i).klass === smalltalk.Number ? $receiver * (($receiver = sin45).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])) : smalltalk.send($receiver, "__star", [($receiver = sin45).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])])).klass === smalltalk.Number ? $receiver - (($receiver = temp).klass === smalltalk.Number ? $receiver * (($receiver = sin15).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])) : smalltalk.send($receiver, "__star", [($receiver = sin15).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])])) : smalltalk.send($receiver, "__minus", [($receiver = temp).klass === smalltalk.Number ? $receiver * (($receiver = sin15).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])) : smalltalk.send($receiver, "__star", [($receiver = sin15).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])])])).klass === smalltalk.Number ? $receiver * smalltalk.send(self, "_tileUnit", []) : smalltalk.send($receiver, "__star", [smalltalk.send(self, "_tileUnit", [])])).klass === smalltalk.Number ? $receiver + smalltalk.send(self, "_mapX", []) : smalltalk.send($receiver, "__plus", [smalltalk.send(self, "_mapX", [])]);ypos = ($receiver = ($receiver = ($receiver = ($receiver = ($receiver = temp).klass === smalltalk.Number ? $receiver * (($receiver = sin15).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])) : smalltalk.send($receiver, "__star", [($receiver = sin15).klass === smalltalk.Number ? $receiver + sin75 : smalltalk.send($receiver, "__plus", [sin75])])).klass === smalltalk.Number ? $receiver / 2 : smalltalk.send($receiver, "__slash", [2])).klass === smalltalk.Number ? $receiver + (($receiver = i).klass === smalltalk.Number ? $receiver * sin135 : smalltalk.send($receiver, "__star", [sin135])) : smalltalk.send($receiver, "__plus", [($receiver = i).klass === smalltalk.Number ? $receiver * sin135 : smalltalk.send($receiver, "__star", [sin135])])).klass === smalltalk.Number ? $receiver * smalltalk.send(self, "_tileUnit", []) : smalltalk.send($receiver, "__star", [smalltalk.send(self, "_tileUnit", [])])).klass === smalltalk.Number ? $receiver + smalltalk.send(self, "_mapY", []) : smalltalk.send($receiver, "__plus", [smalltalk.send(self, "_mapY", [])]);cood = smalltalk.send(smalltalk.Array || Array, "_new_", [2]);smalltalk.send(cood, "_at_put_", [1, xpos]);smalltalk.send(cood, "_at_put_", [2, ypos]);return smalltalk.send(smalltalk.send(smalltalk.send(self, "_cells", []), "_at_", [i]), "_at_put_", [j, smalltalk.send(smalltalk.Cell || Cell, "_newWithContext_cellArray_coods_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_canvas", []), "_element", []), "_getContext_", ["2d"]), cellArray, cood])]);}]);}]);
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_initializeWithMapArray_",
smalltalk.method({
selector: "initializeWithMapArray:",
fn: function (aMapArray) {
    var self = this;
    smalltalk.send(self, "_width_", [smalltalk.send(aMapArray, "_size", [])]);
    smalltalk.send(self, "_height_", [smalltalk.send(smalltalk.send(aMapArray, "_at_", [1]), "_size", [])]);
    smalltalk.send(self, "_mapX_", [($receiver = smalltalk.send(self, "_canvasPadding", [])).klass === smalltalk.Number ? $receiver + (($receiver = ($receiver = smalltalk.send(self, "_height", [])).klass === smalltalk.Number ? $receiver * smalltalk.send(self, "_tileUnit", []) : smalltalk.send($receiver, "__star", [smalltalk.send(self, "_tileUnit", [])])).klass === smalltalk.Number ? $receiver * 1.17 : smalltalk.send($receiver, "__star", [1.17])) : smalltalk.send($receiver, "__plus", [($receiver = ($receiver = smalltalk.send(self, "_height", [])).klass === smalltalk.Number ? $receiver * smalltalk.send(self, "_tileUnit", []) : smalltalk.send($receiver, "__star", [smalltalk.send(self, "_tileUnit", [])])).klass === smalltalk.Number ? $receiver * 1.17 : smalltalk.send($receiver, "__star", [1.17])])]);
    smalltalk.send(self, "_mapY_", [smalltalk.send(self, "_canvasPadding", [])]);
    smalltalk.send(self, "_cells_", [smalltalk.send(smalltalk.Array || Array, "_new_", [smalltalk.send(self, "_width", [])])]);
    smalltalk.send(1, "_to_do_", [smalltalk.send(self, "_width", []), function (i) {return smalltalk.send(smalltalk.send(self, "_cells", []), "_at_put_", [i, smalltalk.send(smalltalk.Array || Array, "_new_", [smalltalk.send(self, "_height", [])])]);}]);
    smalltalk.send(self, "_initializeCellsWithMapArray_", [aMapArray]);
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_mapX",
smalltalk.method({
selector: "mapX",
fn: function () {
    var self = this;
    return self['@mapX'];
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_mapX_",
smalltalk.method({
selector: "mapX:",
fn: function (aLength) {
    var self = this;
    self['@mapX'] = aLength;
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_mapY",
smalltalk.method({
selector: "mapY",
fn: function () {
    var self = this;
    return self['@mapY'];
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_mapY_",
smalltalk.method({
selector: "mapY:",
fn: function (aLength) {
    var self = this;
    self['@mapY'] = aLength;
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_tileUnit",
smalltalk.method({
selector: "tileUnit",
fn: function () {
    var self = this;
    return 50;
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_update",
smalltalk.method({
selector: "update",
fn: function () {
    var self = this;
    smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_canvas", []), "_element", []), "_getContext_", ["2d"]), "_clearRect_y_width_height_", [0, 0, 1366, 768]);
    smalltalk.send(smalltalk.send(self, "_cells", []), "_do_", [function (row) {return smalltalk.send(row, "_do_", [function (cell) {return smalltalk.send(cell, "_draw", []);}]);}]);
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_width",
smalltalk.method({
selector: "width",
fn: function () {
    var self = this;
    return self['@width'];
    return self;
}
}),
smalltalk.Map);

smalltalk.addMethod(
"_width_",
smalltalk.method({
selector: "width:",
fn: function (aLength) {
    var self = this;
    self['@width'] = aLength;
    return self;
}
}),
smalltalk.Map);


smalltalk.addMethod(
"_newWithMapArray_",
smalltalk.method({
selector: "newWithMapArray:",
fn: function (aMapArray) {
    var self = this;
    return smalltalk.send(smalltalk.send(self, "_new", []), "_initializeWithMapArray_", [aMapArray]);
    return self;
}
}),
smalltalk.Map.klass);


